﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySSH.IBLL;
using NHibernate.Criterion;

namespace MySSH.BLL
{
    public class BLLBase<T> : IBLLBase<T> where T : class, new()
    {

        public IDAL.IDALBase<T> DAL { get; set; }

        public void Delete(T entity)
        {
            this.DAL.Delete(entity);
        }


        public void Delete(object id)
        {
            this.Delete(this.Get(id));
        }

        public T Get(object id)
        {
            return this.DAL.Get(id);
        }

        public T Save(T entity)
        {
            return this.DAL.Save(entity);
        }

        public void Update(T entity)
        {
            this.DAL.Update(entity);
        }

        public void SaveOrUpdate(T entity)
        {
            this.DAL.SaveOrUpdate(entity);
        }


        public IList<T> GetListAll()
        {
            return this.DAL.GetListAll();

        }

        public IList<T> GetListByPage(int start, int limit, string sort, string dir, out int totalCount, bool isPage, List<ICriterion> criterion)
        {
            return this.DAL.GetListByPage(start, limit, sort, dir, out totalCount, isPage, criterion);
        }


        public IList<T> GetListByPage(int start, int limit, string sort, string dir, out int totalCount, List<ICriterion> criterion)
        {
            return this.DAL.GetListByPage(start, limit, sort, dir, out totalCount, true, criterion);
        }



        public IQueryable<T> GetQueryByLinq()
        {
            return this.DAL.GetQueryByLinq();
        }


        public NHibernate.IQuery GetQueryByHQL(string queryString)
        {
            return this.DAL.GetQueryByHQL(queryString);
        }


        public NHibernate.ICriteria GetQueryByCriteria()
        {
            return this.DAL.GetQueryByCriteria();
        }


        public NHibernate.ISQLQuery GetQueryBySQL(string queryString)
        {
            return this.DAL.GetQueryBySQL(queryString);
        }
    }
}
